package com.xuxiao.service.impl;

import com.xuxiao.common.ReturnNameAndCardID;
import com.xuxiao.common.TransCord;
import com.xuxiao.entrty.TransInfo;
import com.xuxiao.mapper.TransInfoMapper;
import com.xuxiao.service.TransInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


import java.time.LocalDateTime;
import java.util.List;

@Service
public class TransInfoServiceImpl implements TransInfoService {
    @Autowired
    private TransInfoMapper transInfoMapper;

    @Override
    public void addTransInfo(ReturnNameAndCardID returnNameAndCardID) {
        transInfoMapper.plus(returnNameAndCardID);
        transInfoMapper.reduce(returnNameAndCardID);
        returnNameAndCardID.setTransDate(LocalDateTime.now());
        transInfoMapper.addRecord(returnNameAndCardID);
    }

    @Override
    public void deleteByID(String id) {
        transInfoMapper.deleteByID(id);
    }

    @Override
    public List<TransCord> SelectAll() {
        return transInfoMapper.SelectAll();
    }

    @Override
    public List<TransCord> SelectByID(String id) {
        return transInfoMapper.SelectById(id);
    }

    @Override
    public List<TransCord> SelectByname(String name) {
        return transInfoMapper.SelectByName(name);
    }

    @Override
    public List<TransCord> SelectIncome(String name) {
        return transInfoMapper.SelectIncome(name);
    }

}
